import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:mybaseplus/base/config/DeaultPageConfig.dart';
import 'package:mybaseplus/base/tool/color/FFColor.dart';
import 'package:mybaseplus/base/widget/layout/FFImageButton.dart';
import 'package:mybaseplus/base/widget/layout/FFInk.dart';
import 'package:mybaseplus/base/widget/layout/FFLineContainer.dart';
import 'package:mybaseplus/base/widget/layout/FFTextButton.dart';

///默认页面配置
class ConfigDefaultPageStyle {
  static bool isSetted = false;

  static init() {
    //只赋值一次
    if (isSetted == true) {
      return;
    }
    isSetted = true;

    ///第一次菊花
    DeaultPageConfig().ffFirstLoadingWidget = Container(
      child: Center(
        child: FFImageButton(
          width: 80,
          heigth: 80,
          color: Colors.red,
          child: null,
        ),
      ),
    );

    ///网络错误
    DeaultPageConfig().ffNetErrorFunc = (obj) {
      return Container(
        child: Center(
          child: FFLineContainer(
            direction: Axis.vertical,
            margin: EdgeInsets.only(left: 30.w, right: 30.w),
            crossAxisAlignment: CrossAxisAlignment.center,
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              FFImageButton(
                width: 20.w,
                heigth: 20.w,
                child: FFImageFactory.asset("assets/images/default/Vector.png"),
              ),
              FFTextButton(
                text: "网络错误",
                fontSize: 14.sp,
                fontColor: rgba(226, 227, 221, 1),
                fontLineHeight: 20 / 14.w,
                margin: EdgeInsets.only(top: 10.w),
                maxLines: 10,
                alignment: Alignment.center,
                textAlign: TextAlign.center,
              ),
              FFInk(
                child: FFTextButton(
                  unconstrainedBox: true,
                  text: "重试",
                  fontSize: 14.sp,
                  fontColor: rgba(0, 57, 20, 1),
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.all(Radius.circular(20.w)),
                    color: rgba(71, 226, 113, 1),
                  ),
                  padding: EdgeInsets.symmetric(vertical: 10.w, horizontal: 24.w),
                  margin: EdgeInsets.only(top: 32.w),
                  alignment: Alignment.center,
                  onClick: () {
                    if (obj?.firstRefresh != null) {
                      obj?.firstRefresh!();
                    }
                  },
                ),
              ),
            ],
          ),
        ),
      );
    };

    ///空数据
    DeaultPageConfig().ffNoDataFunc = (obj) {
      return Container(
        child: Center(
          child: FFLineContainer(
            direction: Axis.vertical,
            margin: EdgeInsets.only(left: 30.w, right: 30.w),
            crossAxisAlignment: CrossAxisAlignment.center,
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              FFTextButton(
                text: "空数据",
                fontSize: 14.sp,
                fontColor: rgba(226, 227, 221, 1),
                fontLineHeight: 20 / 14.w,
                margin: EdgeInsets.only(top: 10.w),
                maxLines: 10,
                alignment: Alignment.center,
                textAlign: TextAlign.center,
              ),
            ],
          ),
        ),
      );
    };
  }
}
